package indi.liangli;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args ) throws InterruptedException {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
        RpcConsumer bean = context.getBean(RpcConsumer.class);//bean 由spring管理，不需要new 对象，单例对象由容器启动时创建

        for (int i = 0;i<100;i++){
            Thread.sleep(2000);
            IHelloService helloService = bean.clientProxy(IHelloService.class, "localhost", 6666);
            String msg = helloService.saveUser(new User("张三", 18));
            System.out.println(msg);
        }

       /* String msg2 = helloService.sayHelloWord("kenneth");
        System.out.println(msg+"msg2"+msg2);
        PayMentService payMentService = bean.clientProxy(PayMentService.class, "localhost", 6666);
        boolean isPass = payMentService.checkAmount(new User("张三", 18));
        System.out.println(isPass);*/


    }
}
